package com.qumall.boot.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qumall.boot.entity.User;
import com.qumall.boot.mapper.UserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class UserService extends ServiceImpl<UserMapper, User> {


    public User login(User user) {

        String account=user.getAccount();
       // String  phone=user.getPhone();
       // String  email=user.getEmail();
        QueryWrapper<User> userQueryWrapper = new QueryWrapper<>();
        userQueryWrapper.eq("account",account);
        userQueryWrapper .or().eq("phone",account);
          userQueryWrapper.or() .eq("email",account);
        try {
            User dbUser = getOne(userQueryWrapper);
            String dbpassword = dbUser.getPassword();
            if (dbpassword.equals(user.getPassword())) {
                return dbUser;
            }

        }catch (Exception e){
            log.error("login查询用户异常",e);
        }
         return null;
    }
}
